package myalg.singleton;

/**
 * @author Pavel Belevich
 *         Date: Jun 29, 2012
 *         Time: 2:15:23 PM
 */
public class FinalWrapperFactory {

    private FinalWrapper wrapper;

    public Singleton get() {
        if (wrapper == null) {
            synchronized (this) {
                if (wrapper == null) {
                    wrapper = new FinalWrapper(new DefaultSingleton());
                }
            }
        }
        return wrapper.instance;
    }

    private static class FinalWrapper {

        public final Singleton instance;

        public FinalWrapper(Singleton instance) {
            this.instance = instance;
        }
    }

}
